﻿using System;
using Metozis.SimpleXMLSerialization.Contacts;
using Metozis.SimpleXMLSerialization.Products;

namespace Metozis.SimpleXMLSerialization
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            string exitkey = "0";
            do
            {
                Console.WriteLine("   XML Serialization Examples   ");
                Console.WriteLine("   1. Create Contacts Repository");
                Console.WriteLine("   2. Create Products Repository");
                Console.Write("      Pick a Repository:");

                string repoNum = Console.ReadLine();
                Console.WriteLine("");
                IRepository repo;

                switch (repoNum)
                {
                    case "1":
                        repo = new ContactsRepository("contacts.xml");
                        break;
                    case "2":
                        repo = new ProductsRepository("products.xml");
                        break;
                    default:
                        repo = new ContactsRepository("contacts.xml");
                        Console.WriteLine("No Repository has been selected. Default Repository has been created.");
                        Console.WriteLine("");
                        break;
                }

                repo.WriteXml();
                repo.ReadXml();

                Console.WriteLine("   XML file created.\r\n");
                Console.Write("Press any key to exit program.\r\nTo restart press 1. Input:");
                exitkey = Console.ReadLine();
                Console.Clear();
            } while (exitkey == "1");
        }
    }
}